package com.example.romancalc.core;

import static org.testng.Assert.*;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class RomanCalcTests {

	IRomanCalc romanCalc;

	@BeforeTest
	public void setup() {
		romanCalc = new RomanCalcImpl();
	}

	@DataProvider
	public Object[][] validSamples() {
		return new Object[][] {
				// a) I + I = II
				{ "I", "I", "II" },
				// b) V + I = VI
				{ "V", "I", "VI" },
				// c) I + V = VI
				{ "I", "V", "VI" },
				// d) IX + I = X
				{ "IX", "I", "X" },
				// e) V + V = X
				{ "V", "V", "X" },
				// f) CM + C = M
				{ "CM", "C", "M" },
				// g) MCLI + DXV = MDCLXVI
				{ "MCLI", "DXV", "MDCLXVI" },
				// h) LXXIV + DII = DLXXVI
				{ "LXXIV", "DII", "DLXXVI" } };
	}

	@Test(dataProvider = "validSamples")
	public void testValidSamples(String op1, String op2, String result) {
		assertEquals(romanCalc.add(op1, op2), result);
	}

	@DataProvider
	public Object[][] invalidSamples() {
		return new Object[][] {
				// i) IIX + I = INVALID
				{ "IIX", "I" },
				// j) IVX + I = INVALID
				{ "IVX", "I" } };
	}

	@Test(dataProvider = "invalidSamples", expectedExceptions = RomanNumeralException.class)
	public void testInvalidSamples(String op1, String op2) {
		romanCalc.add(op1, op2);
	}

}
